package com.sc.VenusQueryBeta.presenter.account;


import com.sc.VenusQueryBeta.contract.account.xiugai.XiuGaiContract;
import com.sc.VenusQueryBeta.model.account.xiugai.XiuGaiModel;

import io.reactivex.functions.Consumer;

/**
 * Created by SC-02 on 2018/9/19.
 * 修改密码明细presenter 继承契约类的presenper
 */

public class XiuGaiPresenter extends XiuGaiContract.XiuGaiPresenter {
    @Override
    protected XiuGaiContract.IXiuGaiModel getModel() {
        return XiuGaiModel.newInstance();
    }

    @Override
    public void onStart() {

    }


    /**
     *实例化对象
     */
    public static XiuGaiPresenter newInstance(){
        return new XiuGaiPresenter();
    }

    @Override
    public void userchangepwd(int clientindex, String oldPassword, String newPassword, String serverAddress, String projectName, int serverPort) {
        if (mIView == null || mIModel == null)
            return;
        mRxManager.register(mIModel.userchangepwd(clientindex,oldPassword,newPassword,serverAddress,projectName,serverPort).subscribe(new Consumer<String>() {
            @Override
            public void accept(String userchangepwd) throws Exception {
                if (mIView != null)
                    mIView.userchangepwd(userchangepwd);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                if (mIView != null) {
              //      if (mIView.isVisiable())
                        mIView.showToast("Network error");

                    mIView.showNetworkError(throwable);
                }
            }
        }));

    }
}
